package com.jingtai.platform.controller.merchants;

import com.jingtai.core.entity.BaseEntity;
import com.jingtai.core.entity.merchants.MerchantsInfo;
import com.jingtai.platform.service.merchants.MerchantsInfoService;
import com.jingtai.platform.util.ResultUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.jingtai.validate.swagger.CApiParam;

/**
 * 商户表
 *
 * @author sunlaiqian
 * @date 2020-12-02 18:31:31
 */
@Validated
@RestController
@RequestMapping("/platform/merchantsinfo")
@Api(tags = "商户表")
public class MerchantsInfoController{

    @Autowired
    private MerchantsInfoService merchantsInfoService;


    @ApiOperation("商户表列表查询")
    @GetMapping("/list")
    public ResultUtil aopMerchantsInfoList(@CApiParam(name = "page",value = "页数",required = true,cNotEmpty = true,cIntMin = 1) @RequestParam("page") Integer page,
                              @CApiParam(name = "limit",value = "每页个数",required = true,cNotEmpty = true,cIntMin = 1) @RequestParam("limit") Integer limit,
                              @CApiParam(name = "conditions",value = "查询条件",required = false) @RequestParam("conditions") String conditions){
        return merchantsInfoService.MerchantsInfolist(page, limit, conditions);
    }

    @ApiOperation("商户下拉查")
    @GetMapping("/select")
    public ResultUtil aopMerchantsSelect(){
        return merchantsInfoService.merchantsInfoSelect();
    }


    @ApiOperation("根据ID查询merchantsInfo实体")
    @GetMapping("/getMerchantsInfoById")
    public ResultUtil GetMerchantsInfoById(@CApiParam(name = "id",value = "merchantsInfo实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return merchantsInfoService.getMerchantsInfoById(id);
    }


    @ApiOperation("新增merchantsInfo实体")
    @PostMapping("/add")
    @ApiOperationSupport(ignoreParameters = {"merchantsInfo.id","merchantsInfo.createTime","merchantsInfo.updateTime","merchantsInfo.deleteFlag"})
    public ResultUtil aopAddMerchantsInfo(@RequestBody @Validated({BaseEntity.Create.class}) MerchantsInfo merchantsInfo){
        return merchantsInfoService.addMerchantsInfo(merchantsInfo);
    }

    @ApiOperation("编辑merchantsInfo实体")
    @PostMapping("/edit")
    @ApiOperationSupport(ignoreParameters = {"merchantsInfo.createTime","merchantsInfo.updateTime","merchantsInfo.deleteFlag"})
    public ResultUtil aopEditMerchantsInfo(@RequestBody @Validated({BaseEntity.Update.class}) MerchantsInfo merchantsInfo){
        return merchantsInfoService.editMerchantsInfo(merchantsInfo);
    }

    @ApiOperation("根据ID删除merchantsInfo实体")
    @GetMapping("/delMerchantsInfoById")
    public ResultUtil aopDelMerchantsInfoById(@CApiParam(name = "id",value = "merchantsInfo实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return merchantsInfoService.delMerchantsInfoById(id);
    }

}






